package com.qst.mapreduce.wordcount.shiyansi.timuer;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class Test2CountMapper extends Mapper<LongWritable, Text, Text, IntWritable> {
    @Override
    protected void map(LongWritable key, Text value, Mapper<LongWritable, Text, Text, IntWritable>.Context context) throws IOException, InterruptedException {
        String line = value.toString();
        String[] words = line.split(",");
        int shifoutongguan=Integer.parseInt(words[4]);
        int time=Integer.parseInt(words[3]);
        if(shifoutongguan==1){
            Text outkey = new Text("通关用户的平均游戏时长:");
            IntWritable outValue = new IntWritable(time);
            context.write(outkey, outValue);
        }
    }
}
